package com.sikao.app.ui.base;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.sikao.app.app.AppManager;
import com.sikao.app.view.WindowUtil;

public abstract class BaseActivity extends AppCompatActivity {

	public AppManager appManager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//禁止横屏
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		WindowUtil.setUpStatusBarStyle(this);
		appManager = AppManager.getAppManager();
		appManager.addActivity(this);
		initData();
		initView();
		initListener();
		init();
		Log.d("ActivityName", this.getClass().getName());
		Log.d("ActivityName", this.getClass().getName() + "---------onCreate ");
	}

	protected abstract void initData();

	protected abstract void initView();

	protected abstract void initListener();

	protected abstract void init();


	@Override
	protected void onStart() {
		super.onStart();
		Log.d("ActivityName", this.getClass().getName() + "---------onStart ");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Log.d("ActivityName", this.getClass().getName() + "---------onResume ");
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		Log.d("ActivityName", this.getClass().getName() + "---------onRestart ");
	}

	@Override
	protected void onPause() {
		super.onPause();
		Log.d("ActivityName", this.getClass().getName() + "---------onPause ");
	}

	@Override
	protected void onStop() {
		super.onStop();
		Log.d("ActivityName", this.getClass().getName() + "---------onPause ");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		appManager.finishActivity(this);
		Log.d("ActivityName", this.getClass().getName() + "---------onDestroy ");
	}

	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		Log.d("finalize", this.getClass().getName());
	}

}
